<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="myButton">点我</button>
    <script>
        function wati(time) {
            const startTime = Date.now();
            while (Date.now() - startTime < time) {
                // 等待
            }
        }

        document.getElementById('myButton').addEventListener('click', function() {
            console.log('按钮点击');
        });

        setTimeout(() => {
            console.log('定时器');
        }, 0);

        wati(5000);

    </script>
</body>
</html>